<?php

namespace app\api\controller\dianjian;

use app\common\controller\Api;
use app\admin\model\dianjian\User as UserModel;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function add()
    {
      $name = $this->request->post('name');
      $tel = $this->request->post('tel');
      $content = $this->request->post('content');
      if(!$name || !$tel || !$content){
        $this->error('请填写完整');
      }
      $invite_name = $this->request->post('invite_name','');
      $isHave = UserModel::where('tel', $tel)->find();
      if($isHave){
        $this->error('手机号已存在');
      }
      $data = [
        'name' => $name,
        'tel' => $tel,
        'content' => $content,
        'invite_name' => $invite_name,
      ];
      $res = UserModel::create($data);
      if($res){
        $this->success('请求成功');
      }else{
        $this->error('请求失败');
      }
    }
}
